package com.lab.webSocket.controller;

import com.lab.webSocket.dto.JsonMsgDto;
import com.lab.webSocket.service.FriendListService;
import com.lab.webSocket.webSocket.WebSocketEndPoint;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by xu_jiaHui on 2017/9/7.
 */
@Controller
@RequestMapping("/ws_friendList")
public class FriendListController {
    @Resource
    private FriendListService friendListService;

    @Resource
    private WebSocketEndPoint webSocketEndPoint;

    @ResponseBody
    @RequestMapping("/getFriendList")
    public JsonMsgDto getFriendListByUserAccount(String userAccount) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setSuccess(true);
            jsonMsgDto.setJsonData(webSocketEndPoint.getOnlineList(userAccount));
        } catch (Exception e) {
            jsonMsgDto.setSuccess(false);
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

}
